In [1]:
xxxxxxxxxx
In [2]:
xxxxxxxxxx

Load the example mpg dataset¶

  • mpg : Miles per gallon
In [3]:
xxxxxxxxxx
In [4]:
xxxxxxxxxx
Outputs unchanged
(398, 9)
text/plain
1
 
1
# Observe data
Metadata changed
xxxxxxxxxx
1
 
1
# Observe columns
Metadata changed
xxxxxxxxxx

a.) Types¶

In [5]:
xxxxxxxxxx
Outputs unchanged
mpg             float64
cylinders         int64
displacement    float64
horsepower      float64
weight            int64
acceleration    float64
model_year        int64
origin           object
name             object
dtype: object
text/plain
1
 
1
## b.) missing values
Metadata changed
xxxxxxxxxx
In [6]:
1
 
1
mpg.isnull().sum()
Metadata changed
xxxxxxxxxx
mpg             0
cylinders       0
displacement    0
horsepower      6
weight          0
acceleration    0
model_year      0
origin          0
name            0
dtype: int64
text/plain

Visualization¶

In [7]:
3
 
1
height = 10
2
sizes = (40, 400)
3
alpha = 0.5
Metadata changed
xxxxxxxxxx
In [6]:
In [8]:
4
 
1
# Plot miles per gallon against horsepower with other semantics
2
sns.relplot(x="horsepower", y="mpg", hue="origin", size="weight",
3
            sizes=(40, 400), alpha=.5, palette="muted",
4
            height=6, data=mpg)
⇛⇚
4
 
1
# Plot miles per gallon against horsepower with other semantics
2
sns.relplot(x="horsepower", y="mpg", hue="origin", size="weight",
3
            sizes=sizes, alpha=alpha, palette="muted",
4
            height=height, data=mpg)
Outputs changed
<seaborn.axisgrid.FacetGrid at 0x7f1dfc3b66d8>
<seaborn.axisgrid.FacetGrid at 0x7fd3783f3ac8>
text/plain
Output added
Output deleted
In [ ]:
1
 
1
​
Metadata changed
xxxxxxxxxx